package 设计模式.创建型模式.demo03生成器模式.流式生成demo;

import lombok.Builder;
import 设计模式.创建型模式.demo03生成器模式.cars.Car;
import 设计模式.创建型模式.demo03生成器模式.cars.CarType;
import 设计模式.创建型模式.demo03生成器模式.components.Engine;
import 设计模式.创建型模式.demo03生成器模式.components.GPSNavigator;
import 设计模式.创建型模式.demo03生成器模式.components.TripComputer;

/**
 * @author: 王富贵
 * @description: 流式生成demo
 * @createTime: 2022/11/07 14:44
 */

@Builder
public class FlowCarBuilder{
    private CarType type;
    private int seats;
    private Engine engine;
    private TripComputer tripComputer;
    private GPSNavigator gpsNavigator;


    public FlowCarBuilder setCarType(CarType type) {
        this.type = type;
        return this;
    }

    public FlowCarBuilder setSeats(int seats) {
        this.seats = seats;
        return this;
    }

    public FlowCarBuilder setEngine(Engine engine) {
        this.engine = engine;
        return this;
    }

    public FlowCarBuilder setTripComputer(TripComputer tripComputer) {
        this.tripComputer = tripComputer;
        return this;
    }

    public FlowCarBuilder setGPSNavigator(GPSNavigator gpsNavigator) {
        this.gpsNavigator = gpsNavigator;
        return this;
    }

    public Car getResult() {
        return new Car(type, seats, engine, tripComputer, gpsNavigator);
    }
}
